home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / access / rtree.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.6 KB  |  90 lines

  1. /*
  2.  *  rtree.h -- common declarations for the rtree access method code.
  3.  *
  4.  *    $Header: /private/postgres/src/lib/H/access/RCS/rtree.h,v 1.4 1991/05/22 07:48:42 mao Exp $
  5.  */
  6.  
  7. #ifndef RTreeHIncluded
  8. #define RTreeHIncluded
  9.  
  10. /* see rtstrat.c for what all this is about */
  11. #define RTNStrategies            8
  12. #define RTLeftStrategyNumber        1
  13. #define RTOverLeftStrategyNumber    2
  14. #define RTOverlapStrategyNumber        3
  15. #define RTOverRightStrategyNumber    4
  16. #define RTRightStrategyNumber        5
  17. #define RTSameStrategyNumber        6
  18. #define RTContainsStrategyNumber    7
  19. #define RTContainedByStrategyNumber    8
  20.  
  21. #define RTNProcs            3
  22. #define RT_UNION_PROC            1
  23. #define RT_INTER_PROC            2
  24. #define RT_SIZE_PROC            3
  25.  
  26. #define F_LEAF        (1 << 0)
  27.  
  28. typedef struct RTreePageOpaqueData {
  29.     uint32        flags;
  30. } RTreePageOpaqueData;
  31.  
  32. typedef RTreePageOpaqueData    *RTreePageOpaque;
  33.  
  34. /*
  35.  *  When we descend a tree, we keep a stack of parent pointers.
  36.  */
  37.  
  38. typedef struct RTSTACK {
  39.     struct RTSTACK    *rts_parent;
  40.     OffsetIndex    rts_child;
  41.     BlockNumber    rts_blk;
  42. } RTSTACK;
  43.  
  44. /*
  45.  *  When we're doing a scan, we need to keep track of the parent stack
  46.  *  for the marked and current items.  Also, rtrees have the following
  47.  *  property:  if you're looking for the box (1,1,2,2), on the internal
  48.  *  nodes you have to search for all boxes that *contain* (1,1,2,2), and
  49.  *  not the ones that match it.  We have a private scan key for internal
  50.  *  nodes in the opaque structure for rtrees for this reason.  See
  51.  *  access/index-rtree/rtscan.c and rtstrat.c for how it gets initialized.
  52.  */
  53.  
  54. typedef struct RTreeScanOpaqueData {
  55.     struct RTSTACK    *s_stack;
  56.     struct RTSTACK    *s_markstk;
  57.     uint16        s_flags;
  58.     uint16        s_internalNKey;
  59.     ScanKeyData    s_internalKey;
  60. } RTreeScanOpaqueData;
  61.  
  62. typedef RTreeScanOpaqueData    *RTreeScanOpaque;
  63.  
  64. /*
  65.  *  When we're doing a scan and updating a tree at the same time, the
  66.  *  updates may affect the scan.  We use the flags entry of the scan's
  67.  *  opaque space to record our actual position in response to updates
  68.  *  that we can't handle simply by adjusting pointers.
  69.  */
  70.  
  71. #define RTS_CURBEFORE    ((uint16) (1 << 0))
  72. #define RTS_MRKBEFORE    ((uint16) (1 << 1))
  73.  
  74. /* root page of an rtree */
  75. #define P_ROOT        0
  76.  
  77. /*
  78.  *  When we update a relation on which we're doing a scan, we need to
  79.  *  check the scan and fix it if the update affected any of the pages it
  80.  *  touches.  Otherwise, we can miss records that we should see.  The only
  81.  *  times we need to do this are for deletions and splits.  See the code in
  82.  *  rtscan.c for how the scan is fixed.  These two contants tell us what sort
  83.  *  of operation changed the index.
  84.  */
  85.  
  86. #define    RTOP_DEL    0
  87. #define    RTOP_SPLIT    1
  88.  
  89. #endif /* RTreeHIncluded */
  90.